home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ETO Development Tools 4
/
ETO Development Tools 4.iso
/
Tools - Objects
/
MacsBug
/
MacsBug 6.2.1
/
dcmds
/
C Samples
/
Vol.c
< prev
next >
Wrap
Text File
|
1991-05-01
|
4KB
|
189 lines
/* vol.c
This is the VCB dcmd.
Copyright © 1988 Apple Computer, Inc. All rights reserved.
Modification history:
29Nov88 sad revised for new dcmd names. display more info.
5Oct88 sad written.
The following MPW commands will build the dcmd and copy it to the
"Debugger Prefs" file in the System folder. The dcmd's name in
MacsBug will be the name of the file built by the Linker.
You must first copy dcmd.h, dcmdGlue.a.o and DRunTime.o from the
C Samples folder into this folder.
C Put.c
C Vol.c
Link dcmdGlue.a.o Vol.c.o put.c.o DRuntime.o "{Libraries}"Interface.o -o Vol
BuildDcmd Vol 1002
Echo 'include "Vol";' | Rez -a -o "{systemFolder}Debugger Prefs"
*/
#include <Types.h>
#include <Memory.h>
#include <OSUtils.h>
#include <Files.h>
#include "dcmd.h"
#include "put.h"
#define VCBQHdr ((QHdrPtr)0x356)
static void DrawHdr()
{
// 1 2 3 4 5 6 7
// 1234567890123456789012345678901234567890123456789012345678901234567890123456789
dcmdDrawLine("\pvRef Vol Flg dRef Drive FSID #Blk BlkSiz #Files #Dirs Blsd Dir VCB at");
}
static void DrawVCB(VCB* vcbp)
{
PutUHexWord(vcbp->vcbVRefNum);
PutSpace();
PutPStrTruncTo(vcbp->vcbVN,15);
PutSpace();
PutChar((vcbp->vcbFlags & 0x8000) ? 'D' : 'd');
PutChar((vcbp->vcbAtrb & 0x8000) ? 'S' : 's');
PutChar((vcbp->vcbAtrb & 0x4000) ? 'H' : 'h');
PutSpace();
PutUHexWord(vcbp->vcbDRefNum);
PutSpace();
PutSpace();
PutUHexWord(vcbp->vcbDrvNum);
PutSpace();
PutUHexWord(vcbp->vcbFSID);
PutSpace();
PutUHexWord(vcbp->vcbNmAlBlks);
PutSpace();
PutUHexZTo(vcbp->vcbAlBlkSiz,6,47);
PutSpace();
PutUHexZTo(vcbp->vcbFilCnt,6,54);
PutSpace();
PutUHexZTo(vcbp->vcbDirCnt,6,61);
PutSpace();
PutUHexZTo(vcbp->vcbFndrInfo[0],6,70);
PutSpace();
PutUHexZTo((unsigned long)vcbp,6,77);
PutLine();
}
static Boolean PrefixPStr(const Str255 astr, const Str255 bstr)
// returns true if astr is equal to a prefix of bstr
// astr must not be longer than 31 characters
{
char newstr[31];
int alen = *astr;
int blen = *bstr;
if (alen <= blen)
{
BlockMove(bstr+1,newstr+1,alen);
newstr[0] = alen;
return EqualString(astr,newstr,false,true);
}
else return false;
} // PrefixPStr
// EJECT
pascal void CommandEntry(dcmdBlock* paramPtr)
{
switch (paramPtr->request)
{
case dcmdInit:
break;
case dcmdHelp:
dcmdDrawLine("\pvol [vRefNum|drvNum|\"vol name\"]");
dcmdDrawLine("\p Displays volume information for the given vrefnum, volume name or all mounted volumes.");
dcmdDrawLine("\p Flags are D/d=Dirty, S/s=Software locked, H/h=Hardware locked.");
break;
case dcmdDoIt:
{
Boolean doOneVCB = false;
long vref;
short c;
Boolean haveVolName = false;
Str255 volname;
VCB* vcbp;
int numvcbs = 0;
Boolean foundOne = false;
dcmdSwapWorlds();
dcmdDrawLine("\pDisplaying Volume Control Blocks");
// get low-memory values after dcmdSwapWorlds()
vcbp = (VCB*)(VCBQHdr->qHead);
c = dcmdPeekAtNextChar();
if (c == '"' || c == '\'')
{
haveVolName = true;
(void)dcmdGetNextParameter(volname);
}
else (void)dcmdGetNextExpression(&vref, &doOneVCB);
if (doOneVCB) vref = (short)vref;
while (vcbp)
{
if ((doOneVCB && (vcbp->vcbVRefNum == vref || vcbp->vcbDrvNum == vref)) ||
(haveVolName && PrefixPStr(volname,vcbp->vcbVN)) ||
(!doOneVCB && !haveVolName))
{
numvcbs++;
if (!foundOne)
{
DrawHdr();
foundOne = true;
}
DrawVCB(vcbp);
}
if (paramPtr->aborted) break;
if (vcbp->qLink == 0)
if (vcbp != (VCB*)(VCBQHdr->qTail))
dcmdDrawLine("\pVCB queue does not end at VCBQHdr.qTail");
vcbp = (VCB*)vcbp->qLink;
}
if (!paramPtr->aborted)
if (haveVolName || doOneVCB)
{
if (!foundOne)
if (haveVolName)
{
PutPStr("\pno mounted volumes match \"");
PutPStr(volname);
PutChar('"');
PutLine();
}
else
{
PutPStr("\pno mounted volumes match ");
PutUHexWord(vref);
PutLine();
}
}
else
{
PutUDec(numvcbs);
PutPStr("\p VCBs");
PutLine();
}
dcmdSwapWorlds();
}
break;
default:
PutPStr("\punknown request ");
PutUDec(paramPtr->request);
PutLine();
break;
}
} // CommandEntry